﻿<BadHabit_WPFTools:ShapedWindow
    x:Class="BadHabit.Factory.Views.TeamAllocation"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Microsoft_Toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools"     
    xmlns:BadHabit_WPFTools_Converters="clr-namespace:BadHabit.WPFTools.Converters;assembly=BadHabit.WPFTools"
    
    xmlns:props="clr-namespace:BadHabit.Factory.Windows.Properties"              
        

    Style="{StaticResource NormalWindow}"
    ResizeMode="CanResizeWithGrip"     
            
    Title="{x:Static props:Resources.Team_Allocation}"
    Loaded="ShapedWindow_Loaded"
    Height="600"
    Width="800"
    Icon="/Images/WindowsIcons/Factory.ico">
    
    <BadHabit_WPFTools:ShapedWindow.Resources>
        
        

        <DataTemplate x:Key="TaskTemplate">
            <Border
                HorizontalAlignment="Center"                  
                CornerRadius="3"                
                Margin="0,2,0,0"
                Opacity="0.85"
                Padding="3"
                Width="60"
                Height="{Binding PlannedEffort, Converter={StaticResource MultiplyConverter}, ConverterParameter=25}"
                ToolTip="{StaticResource TaskToolTip}">

                <TextBlock Text="{Binding TaskName}" TextWrapping="Wrap" VerticalAlignment="Top"/>

                <Border.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Status}" Value="0">
                                <Setter Property="Border.Background" Value="{StaticResource ToDoBrush}"/>
                                <Setter Property="Border.BorderBrush" Value="{StaticResource ToDoBorderBrush}"/>
                                <Setter Property="Border.BorderThickness" Value="2"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Status}" Value="1">
                                <Setter Property="Border.Background" Value="{StaticResource ToDoBrush}"/>
                                <Setter Property="Border.BorderBrush" Value="{StaticResource ToDoBorderBrush}"/>
                                <Setter Property="Border.BorderThickness" Value="2"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Status}" Value="2">
                                <Setter Property="Border.Background" Value="{StaticResource WorkingBrush}"/>
                                <Setter Property="Border.BorderBrush" Value="{StaticResource WorkingBorderBrush}"/>
                                <Setter Property="Border.BorderThickness" Value="2"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding IsWorking}" Value="true">
                                <Setter Property="Border.BorderBrush" Value="{StaticResource DarkBrush}"/>
                                <Setter Property="Border.BorderThickness" Value="3"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Style>
            </Border>
        </DataTemplate>


        <DataTemplate x:Key="MemberTemplate">
            <StackPanel Orientation="Vertical" Background="Transparent">
                <ContentControl 
                    Style="{StaticResource TeamMemberImageControl}"
                    Width="44" Height="44" Margin="0,2,0,0" />

                <TextBlock Text="{Binding NickName}" TextAlignment="Center" Width="80" TextWrapping="Wrap" Height="30" Margin="0,3,0,0" Foreground="{StaticResource DarkTextBrush}"/>
                
                <TextBlock Text="{Binding AvailableAt, StringFormat='{}{0:d}'}" TextAlignment="Center" FontSize="{StaticResource NeedToSeeFontSize}" FontWeight="Bold" />
                
                <TextBlock Text="{Binding ProjectCount, StringFormat='{}{0} project(s)'}" TextAlignment="Center" Foreground="Gray" />
                
                <ListBox
                    BorderThickness="0"
                    HorizontalAlignment="Center"
                    Background="Transparent"
                    Loaded="taskListView_Loaded"
                    ItemTemplate="{StaticResource TaskTemplate}"
                    />                    
            </StackPanel>    
        </DataTemplate>

  
        <VisualBrush x:Key="ScaleVisualBrush" AutoLayoutContent="True" TileMode="None" Stretch="None" AlignmentX="Left" AlignmentY="Top">
            <VisualBrush.Visual>
                <Canvas x:Name="scaleCanvas" Background="White"/>
            </VisualBrush.Visual>
        </VisualBrush>



    </BadHabit_WPFTools:ShapedWindow.Resources>

    <Grid Background="{StaticResource GradientSilverTubeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>    
        </Grid.RowDefinitions>

        <ToolBar  x:Name="ToolBar" Grid.Row="0" ToolBarTray.IsLocked="True">
            
           
            <TextBlock VerticalAlignment="Center" Style="{StaticResource Label}" Text="{x:Static props:Resources.Search}"/>
            <TextBox x:Name="searchTextBox" Width="150" Style="{StaticResource FilterTextBox}"  SelectionChanged="searchTextBox_SelectionChanged"  />

            <TextBlock VerticalAlignment="Center" Style="{StaticResource Label}" Text="{x:Static props:Resources.Free_at}" />
            <Microsoft_Toolkit:DatePicker VerticalAlignment="Center" x:Name="freeAtDatePicker" SelectedDateChanged="freeAtDatePicker_SelectedDateChanged"/>



            <Menu>
                <MenuItem                                
                x:Name="myProjectButton"
                Style="{StaticResource ToolBarMenuItem}"                         
                Click="idleButton_Click"
                    IsCheckable="True"
                Header="{x:Static props:Resources.My_Projects}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ProjectStatus/prjRunning.png" Stretch="Uniform" Width="32" Height="32"/>
                    </MenuItem.Icon>
                </MenuItem>


                <MenuItem                                
                x:Name="idleButton"    
                Style="{StaticResource ToolBarMenuItem}"     
                Click="idleButton_Click"
                    IsCheckable="True"
                Header="{x:Static props:Resources.Idles}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/Coffe.png" Stretch="Uniform" Width="32" Height="32"/>
                    </MenuItem.Icon>
                </MenuItem>

                <MenuItem                                
                x:Name="availableButton"                    
                Style="{StaticResource ToolBarMenuItem}"     
                Click="idleButton_Click"
                    IsCheckable="True"
                Header="{x:Static props:Resources.No_Tasks}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/TeamMember.png" Stretch="Uniform" Width="32" Height="32"/>
                    </MenuItem.Icon>
                </MenuItem>


                <MenuItem                                
                x:Name="refreshtButton"                      
                Style="{StaticResource ToolBarMenuItem}"     
                Click="refreshtButton_Click"
                Header="{x:Static props:Resources.Refresh}">
                    <MenuItem.Icon>
                        <Image Source="/Images/Toolbar/Refresh.png" Stretch="Uniform" Width="32" Height="32"/>
                    </MenuItem.Icon>
                </MenuItem>
            </Menu>



      
            
        </ToolBar>

        <Border
                Grid.Row="1"                
                Style="{StaticResource RoundBorder}"
                Margin="3">

            <ScrollViewer
                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
                <StackPanel Background="{StaticResource ScaleVisualBrush}">
                    <ListBox
                        x:Name="memberListView"
                        ItemContainerStyle="{StaticResource NoSelectionListBoxItem}"
                        BorderThickness="0"
                        Margin="60,0,0,0"
                        Background="Transparent"
                        VerticalContentAlignment="Top"
                        ScrollViewer.VerticalScrollBarVisibility="Disabled"
                        ScrollViewer.HorizontalScrollBarVisibility="Disabled"                        
                        ItemTemplate="{StaticResource MemberTemplate}">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" Background="Transparent" />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </StackPanel>
            </ScrollViewer>

      
        </Border>


        

    
    </Grid>


</BadHabit_WPFTools:ShapedWindow>
